﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Globalization;
using RealEstate.Common;

namespace RealEstate.Models
{
    public partial class TRANSACTION
    {
        public string ClientCoClientName
        {
            get
            {
                if (this.Client != null && !string.IsNullOrEmpty(this.Client.FullName) && this.Client1 != null && !string.IsNullOrEmpty(this.Client1.FullName))
                {
                    return string.Concat(this.Client.FullName, ", ", this.Client1.FullName);
                }
                else if (this.Client != null && !string.IsNullOrEmpty(this.Client.FullName))
                {
                    return this.Client.FullName;
                }
                else if (this.Client1 != null && !string.IsNullOrEmpty(this.Client1.FullName))
                {
                    return this.Client1.FullName;
                }

                return null;
            }
        }

        public string CaseStatus
        {
            get
            {
                if (this.Status != null && !string.IsNullOrEmpty(this.Status.Status1))
                {
                    return this.Status.Status1;
                }

                return null;
            }
        }

        public string ClientLastName
        {
            get
            {
                if (this.Client != null && !string.IsNullOrEmpty(this.Client.LastName))
                {
                    return this.Client.LastName;
                }

                return null;
            }
        }

        public string CoClientLastName
        {
            get
            {
                if (this.Client1 != null && !string.IsNullOrEmpty(this.Client1.LastName))
                {
                    return this.Client1.LastName;
                }

                return null;
            }
        }

        public string MyTotalGrossIncome
        {
            get
            {
                decimal? myGrossIncome = 0;
                if (this._MyGrossIncome != null && this._TransactionFee != null)
                {
                    myGrossIncome = this._MyGrossIncome + this._TransactionFee;
                }
                else if (this._MyGrossIncome != null)
                {
                    myGrossIncome = this._MyGrossIncome;
                }
                else if (this._TransactionFee != null)
                {
                    myGrossIncome = this._TransactionFee;
                }

                if (myGrossIncome > 0)
                    return Utilities.ConvertCurrency(myGrossIncome);
                return string.Empty;
            }
        }

        public string SubjectProperty
        {
            get
            {
                if (Property1 != null && Property1.SubjectProperty != null)
                {
                    return Property1.SubjectProperty;
                }

                return null;
            }
        }

        public string YearGroup
        {
            get
            {
                if (this.DateOfStatus != null)
                {
                    return this.DateOfStatus.Value.Year.ToString();
                }

                return null;
            }
        }

        public string MonthName
        {
            get
            {
                if (this.DateOfStatus != null)
                {
                    return this.DateOfStatus.Value.ToString("MMM");
                }

                return null;
            }
        }

        public string MonthGroup
        {
            get
            {
                if (this.DateOfStatus != null)
                {
                    return this.DateOfStatus.Value.Month.ToString();
                }

                return null;
            }
        }
    }
}